  layui.config({
     base: CXL.ctxPath + '/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
      var form = layui.form;


      $('#btnSearch').click(function () {
            var carLicense = $("#carLicense").val();
          	$.ajax({
                 type: "post",
                 url: CXL.ctxPath + '/sys/entrance/getMaterial',
                 data: {carLicense:carLicense},
                 success: function(res) {
                     if(res.success) {
                         console.log(res);
                         CXL.success(res.msg);
                         //表格删除
                         $("material").val(res.data);
                     }else {
                         CXL.warn(res.msg);
                     }
                 }
          	});
      });

        //监听提交
        form.on('submit(form-btn-save)', function(data){

            var param = data.field;
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                   type: "post",
                   url: CXL.ctxPath + '/sys/entrance/open',
                   data: param,
                   success: function(res) {
                       if(res.success) {
                           CXL.success(res.msg);
                           parent.layui.table.reload('sys-entrance-table'); //重载表格
                           parent.layer.close(index); //再执行关闭
                       }else {
                           CXL.warn(res.msg);
                       }
                   }
               });

        });




});